package folexpr.compiler.visitors.f_prenexcong;

import java.util.Iterator;
import java.util.Vector;

import folexpr.compiler.CompilerConstants;
import folexpr.compiler.visitors.VisitResult;

public class CongPrenexFormVisitResult extends VisitResult
{
	private Vector<String> elementiInAnd;
	
	public CongPrenexFormVisitResult()
	{
		super();
		elementiInAnd = new Vector<String>();
	}
	
	public CongPrenexFormVisitResult(CongPrenexFormVisitResult copy)
	{
		super();	
	}
	
	public Vector<String> getElementiInAnd() {
		return elementiInAnd;
	}

	public void setElementiInAnd(Vector<String> elementiInAnd) {
		this.elementiInAnd = elementiInAnd;
	}
	
	public void generateAndSetPrenexFormFromVector(boolean finalResult)
	{	
		Iterator i = this.elementiInAnd.iterator();
		boolean first = true;
		
		String image="";
			
		while (i.hasNext())
		{
			String element = (String)i.next();
			
			if (first) {
				this.setResultExpr( (finalResult ? "" : CompilerConstants._openImage ) + element + (finalResult ? "" : CompilerConstants._closeImage) );
			}
			else {
				this.setResultExpr(this.getResultExpr() + " " + CompilerConstants.andImage + " " + 
						(finalResult ? "" : CompilerConstants._openImage) + element + (finalResult ? "" : CompilerConstants._closeImage ) ); 
			}
			
			first = false;
		}

	}
	
	
}
